package com.gxa.service.parking.impl;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.entity.parking.Parking;
import com.gxa.mapper.parking.ParkingMapper;
import com.gxa.service.parking.ParkingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yjl
 * @since 2022-10-11 10:05:39
 */
@Service
public class ParkingServiceImpl extends ServiceImpl<ParkingMapper, Parking> implements ParkingService {

    @Autowired
    private ParkingMapper parkingMapper;
    @Override
    public PageInfo<Parking> selectAll(Parking parking,Integer pageNum,Integer pageSize) {
        QueryWrapper<Parking> wrapper = new QueryWrapper<>();
        wrapper.like(parking.getParkingNum() != null, "parking_num", parking.getParkingNum())
                .like(parking.getParkingName() != null, "parking_name", parking.getParkingName())
                .eq(null != parking.getParkingType(), "parking_type", parking.getParkingType());
        Page page = PageHelper.startPage(pageNum, pageSize);
        List<Parking> parkings = parkingMapper.selectList(wrapper);
        PageInfo<Parking> parkingPageInfo = new PageInfo<>(parkings);
        return parkingPageInfo;
    }

    @Override
    public Parking queryById(Integer id) {
        Parking parking = parkingMapper.selectById(id);
        return parking;
    }

    @Override
    public void add(Parking parking) {
        parkingMapper.insert(parking);
    }

    @Override
    public void deleteById(Integer id) {
        parkingMapper.deleteById(id);
    }

    @Override
    public void update(Parking parking) {
        parkingMapper.updateById(parking);
    }

//    @Override
//    public List<Parking> selectByCondition() {
//        return parkingMapper.selectByCondition();
//    }
}
